sales <- read_csv("sales.csv") %>%
mutate(net = price - cost - shipping) %>%
filter(region == params$region) %>%
filter_by_time(date, params$startdate, params$enddate)
This report summarizes sales of our 3 products in the North America region between 2018-01-01 and 2021-04-23.
monthly_sales_by_model <- sales %>%
group_by(model) %>%
summarize_by_time(date, "month", sales = n())
monthly_sales_by_model %>%
ungroup() %>%
plot_time_series(date, sales, .color_var = model, .smooth = FALSE, .interactive = FALSE,
.title = "Monthly Sales by Model - Last 12 Months",
.color_lab = "Model")
reactable(monthly_sales_by_model,
resizable = TRUE,
filterable = TRUE,
searchable = TRUE)
monthly_sales_by_model %>%
plot_anomaly_diagnostics(date, sales, .alpha = .25)
ggplot(sales, aes(x = model, y = net, color = model)) +
geom_jitter(alpha = .25) +
geom_point(stat = "summary", size = 5) +
theme_minimal() +
theme(legend.position = "none") +
labs(title = "Profit by Model",
x = "Model",
y = "Profit")
sales_by_returning <- sales %>%
group_by(returning, model) %>%
count()
sales_by_returning %>%
ggplot(aes(x = returning, y = n, fill = model)) +
geom_bar(stat = "identity", position = "dodge") +
theme_minimal() +
labs(title = "Sales by Model and New vs. Returning Customer",
x = "Returning customer?",
y = "Sales",
fill = "Model")